package com.xerokhan.diary.util;

import java.util.Date;

public class DateUtil {

	public static long getMonthsFrom1900(Date to) {
		return to.getYear() * 12 + to.getMonth() + 1;
	}

	public static long getYearsFrom1900(Date to) {
		return to.getYear() - 1900;
	}

	public static long getHoursFrom1900(Date to) {
		Date from = new Date(0, 0, 1);
		long diff = to.getTime() - from.getTime();
		long hour = 3600000;
		if (diff % hour == 0) {
			return diff / hour;
		} else
			return 1 + diff / hour;
	}

	public static long getDaysFrom1900(Date to) {
		Date from = new Date(0, 0, 1);
		long diff = to.getTime() - from.getTime();
		long day = 24 * 3600000;
		if (diff % day == 0) {
			return diff / day;
		} else
			return 1 + diff / day;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Date d = new Date();
		d.setMonth(12);
		System.out.println(d);
	}
}
